#pragma once 

#include "HttpRequest.h"
#include "buffer.h"
#define MAX_LINE 8196

typedef enum{
    RECV_HTTP_ERR,
    RECV_HTTP_LINE,
    RECV_HTTP_HEAD,
    RECV_HTTP_BODY,
    RECV_HTTP_OVER,
}HttpRecvStatu;
namespace muduo{

    class HttpContext{
    private:
        HttpRequest _request;       //已经解析得到的请求信息
        int _resp_statu;            //响应状态码
        HttpRecvStatu _recv_statu;  //接收状态码
    private:
        bool ParseHttpLine(std::string& line);
        bool RecvHttpLine(Buffer* buf);
        bool ParseHttpHead(std::string& line);
        bool RecvHttpHead( Buffer* buf);
        bool RecvHttpBody(Buffer* buf);
    public:
        HttpContext();
        void Reset();
        HttpRequest& Request();
        int RespStatu();    //获得响应状态码
        HttpRecvStatu Recvstatu();  //获得接收状态码
        void RecvHttpRequest(Buffer* buf); //接收并处理Http请求
    };
}